package com.kczd.jinlan.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.kczd.jinlan.R;

import cn.pedant.SweetAlert.SweetAlertDialog;

/**
 * yang_g
 * 设置
 * Created by Administrator on 2017/5/15.
 */

public class SetupActivity extends Activity implements View.OnClickListener {
    private LinearLayout linear_Opinion;
    private TextView id_fanhui;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setup_activity);
    }

    @Override
    public void onContentChanged() {
        super.onContentChanged();
        linear_Opinion = (LinearLayout) findViewById(R.id.linear_Opinion);
        linear_Opinion.setOnClickListener(this);
        id_fanhui = (TextView) findViewById(R.id.id_fanhui);
        id_fanhui.setOnClickListener(this);
        findViewById(R.id.ll_logout).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.linear_Opinion://意见反馈
                startActivity(new Intent(SetupActivity.this, OpinionActivity.class));
                break;
            case R.id.id_fanhui://返回
                finish();
                break;
            case R.id.ll_logout://退出
                new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE).setTitleText("提示")
                        .setContentText("你确定退出登录吗？")
                        .setCancelText("取消")
                        .setConfirmText("确定")
                        .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
                            @Override
                            public void onClick(SweetAlertDialog sDialog) {
                                SharedPreferences.Editor editor=getSharedPreferences("data",0).edit();
                                editor.putString("token",null);
                                editor.commit();
                                startActivity(new Intent(SetupActivity.this, LoginActivity.class));//打开登录页面
                                // 退出设置页面
                                finish();
                                sDialog.cancel();
                            }
                        }).showCancelButton(true)
                        .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
                            @Override
                            public void onClick(SweetAlertDialog sDialog) {
                                sDialog.cancel();
                            }
                        }).show();
        }
    }
}
